//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.Research.DataLayer
{
    /// <summary>
    /// Base exception class for Data Layer services
    /// </summary>
    public class DataLayerException : Exception
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public DataLayerException()
            : base()
        {
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="msg"></param>
        public DataLayerException(string msg)
            : base(msg)
        {
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="inner"></param>
        public DataLayerException(string msg, Exception inner)
            : base(msg, inner)
        {
        }
    }

    /// <summary>
    /// Used to notify user cancelled the connection picker
    /// </summary>
    public class UserCancelledConnectionPicker : Exception
    {
        /// <summary>
        /// Constructor
        /// </summary>
        public UserCancelledConnectionPicker()
        {
        }
    }

    public class InvalidProviderConfiguration : Exception
    {
        public InvalidProviderConfiguration()
        {
        }
    }

    public class ConnectionStoreFileNotFound : Exception
    {
        private string file;

        public string StoreFile { get { return file; } }

        public ConnectionStoreFileNotFound(string file)
        {
            this.file = file;
        }
    }

    public class ConnectionStoreFileAlreadyExists : Exception
    {
        private string file;

        public string StoreFile { get { return file; } }

        public ConnectionStoreFileAlreadyExists(string file)
        {
            this.file = file;
        }
    }

    /// <summary>
    /// This exception is thrown when a provider handle is duplicate
    /// in the system. That means that two modules claim to handle the
    /// same provider (e.g. "sqlserver"). This conflict cannot be 
    /// resolved by the software and processing will halt.
    /// </summary>
    public class ProviderDuplicateException : Exception
    {
        public ProviderDuplicateException()
        {
        }
    }

    /// <summary>
    /// This exception is thrown when a provider information is present
    /// in the configuration file but we do not have a provider to handle
    /// it. To avoid data loss the system will stop the processing until
    /// error is fixed.
    /// </summary>
    public class ProviderMissingException : Exception
    {
        private string provider;

        public string ProviderKey { get { return provider; } }

        public ProviderMissingException(string provider)
        {
            this.provider = provider;
        }
    }

    /// <summary>
    /// This exception is thrown when a provider information is present
    /// in the configuration file but we do not have a provider to handle
    /// it. To avoid data loss the system will stop the processing until
    /// error is fixed.
    /// </summary>
    public class ProviderMissingException2 : Exception
    {
        private IConnMgrInfoParams conn;

        public IConnMgrInfoParams UnhanldedConnection { get { return conn; } }

        public ProviderMissingException2(IConnMgrInfoParams conn)
        {
            this.conn = conn;
        }
    }

    /// <summary>
    /// This exception is thrown when the connection being requested does not
    /// exist or it is not saved by connection manager
    /// </summary>
    public class ConnectionNotFoundException : Exception
    {
        public ConnectionNotFoundException()
        {
        }
    }

    /// <summary>
    /// Thrown if the lite dialog is invoked in "management" mode, which it
    /// does not support.
    /// </summary>
    public class CannotManageWithLiteDialogException : Exception
    {
        public CannotManageWithLiteDialogException()
        {
        }
    }

    /// <summary>
    /// Cannot merge template with another template
    /// </summary>
    public class InvalidTargetForMergeException : DataLayerException
    {
        public InvalidTargetForMergeException()
        {
        }
    }
}
